package com.smart.alipay.controller;

import com.netflix.client.http.HttpRequest;
import com.smart.alipay.dto.PayInfo;
import com.smart.alipay.service.PayService;
import com.smart.common.result.BaseResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * H5   APP
 */
@RestController
@RequestMapping("/ali")
public class AliPayController {
    @Resource
    private PayService payService;

    @GetMapping("pay")
    public BaseResult<String> alipay(PayInfo payInfo) throws Exception{
        BaseResult<String> pay = payService.pay(payInfo.getOrderNo(), payInfo.getTotal(), payInfo.getSubject());
        return pay;
    }

    @GetMapping("payWeb")
    public BaseResult<String> payWeb(PayInfo payInfo) throws Exception{
        BaseResult<String> pay = payService.payWeb(payInfo.getOrderNo(), payInfo.getTotal(), payInfo.getSubject());
        return pay;
    }


    @PostMapping("/pay/callback")
    public String  callback(HttpRequest  request){
        return "success";
    }

}
